package com.qf04;

public class Ticket implements Runnable {
    private int ticket = 100;
//    private Object obj = new Object();

    @Override
    public void run() {
        while (true) {
            synchronized (this) {
                if (ticket <= 0) {
                    break;
                }
                System.out.println(Thread.currentThread().getName() + "卖了第" + ticket + "张票");
                ticket--;
            }
        }
    }
}
